﻿using System;
using System.Drawing;

namespace ClockwiseClient
{
    public class ClassStock
    {
        public static string strWorkDir = null;
        public static string strShWorkDir = null;
        public static string strSzWorkDir = null;
        public static string strHkWorkDir = null;
        public static string strUsWorkDir = null;

        public static ClassStock GetInstance()
        {
            if (classStock == null) classStock = new ClassStockData();
            return classStock;
        }

        static ClassStock classStock = null;

        public static Brush CalcColor(float value, float refer)
        {
            if (value < 0.001) return Brushes.Gray;
            if (value > refer) return Brushes.Red;
            if (value < refer) return Brushes.Green;
            return Brushes.White;
        }

        public static String AmountFormat(float amount)
        {
            if (amount < 100000000f)
            {
                if (amount < 10000)
                {
                    return amount.ToString("f2");
                }
                else
                if (amount < 1000000)
                {
                    return (amount / 10000).ToString("f2") + "万";
                }
                else
                {
                    return (amount / 10000).ToString("f0") + "万";
                }
            }
            return (amount / 100000000).ToString("f2") + "亿";
        }

        public static String VolumeFormat(float amount)
        {
            if (amount < 100000000f)
            {
                if (amount < 10000)
                {
                    return amount.ToString("f0") + "手";
                }
                else
                if (amount < 1000000)
                {
                    return (amount / 10000).ToString("f2") + "万";
                }
                else
                {
                    return (amount / 10000).ToString("f0") + "万";
                }
            }
            return (amount / 100000000).ToString("f2") + "亿";
        }
    }
}
